package com.hbt.en_rem_hou.dao;

import com.hbt.en_rem_hou.entitys.Word;
import com.hbt.en_rem_hou.entitys.WordsCondition;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WordDao {

    @Select("select count(*) from word where userid = #{userid}")
    public int getTotalCountByUserId(int userid);

    @Select("select count(*) from word where cmd = '很熟练' and userid = #{userid}")
    public int getHenCmdCountByUserId(int userid);
    @Select("select count(*) from word where cmd = '熟练' and userid = #{userid}")
    public int getCmdCountByUserId(int userid);
    @Select("select count(*) from word where cmd = '不熟练' and userid = #{userid}")
    public int getNoCmdCountByUserId(int userid);

    @Select("select count(*) from word where imp = '很重要' and userid = #{userid}")
    public int getHenImpCountByUserID(int userid);
    @Select("select count(*) from word where imp = '重要' and userid = #{userid}")
    public int getImpCountByUserID(int userid);
    @Select("select count(*) from word where imp = '不重要' and userid = #{userid}")
    public int getNoImpCountByUserID(int userid);


    @Delete("delete from word where id = #{wordid}")
    public int deleteWordByWordId(int wordid);

    @Update("update word set cmd = #{cmd} where id = #{id}")
    public int updateCmdByCmdAndWordId(Word word);

    @Update("update word set imp = #{imp} where id = #{id}")
    public int updateImpByImdAndWordId(Word word);

    @Update("update word set tgt = #{tgt}  where id = #{id}")
    public int updateTgtByWordId(Word word);

    public Word getWordByWordId(int wordid);
//    @Insert("insert into word (userid, src, tgt, cmd, imp) values (#{userid}, #{src}, #{tgt}, #{cmd}, #{imp})")
    public int insertWord(Word word);

//    @Select("select *from word where userid = #{userid} and src = #{src}")
    public Word getWordByuserIdAndSrc(Word word);

    public List<Word> getWordsByCondition(WordsCondition wordsCondition);
}
